SIZE_1M = 0x100000
SIZE_1K = 1024


# Only attributes in class MemoryMap are generated to .h
class MemoryMap:
    # No prefix "CVIMMAP_" for the items in _no_prefix[]
    _no_prefix = [
        "CONFIG_SYS_TEXT_BASE"  # u-boot's CONFIG_SYS_TEXT_BASE is used without CPP.
    ]

    DRAM_BASE = 0x100000000
    DRAM_SIZE = 2047 * SIZE_1M

    # Bootlogo
    BOOTLOGO_ADDR = DRAM_BASE + 24 * SIZE_1M
    BOOTLOGO_SIZE = 1.5 * SIZE_1M

    # C906L freertos
    FREERTOS_SIZE = 2 * SIZE_1M
    FREERTOS_ADDR = DRAM_BASE + DRAM_SIZE - FREERTOS_SIZE
    # psu_ddr_0_MEM_0 : ORIGIN = FREERTOS_ADDR, LENGTH = FREERTOS_SIZE

    # OpenSBI | arm-trusted-firmware
    MONITOR_ADDR = DRAM_BASE

    ATF_SIZE = 512 * SIZE_1K

    OPENSBI_SIZE = 512 * SIZE_1K
    OPENSBI_FDT_ADDR = DRAM_BASE + SIZE_1M

    # FSBL
    FSBL_UNZIP_ADDR = DRAM_BASE + 16 * SIZE_1M
    FSBL_UNZIP_SIZE = DRAM_BASE + 4 * SIZE_1M
    FSBL_C906L_START_ADDR = FREERTOS_ADDR

    # uboot-2021 defconfig
    CONFIG_SYS_TEXT_BASE = DRAM_BASE + 640 * SIZE_1K
    CONFIG_SYS_INIT_SP_ADDR = DRAM_BASE + 63 * SIZE_1M

    UIMAG_ADDR = DRAM_BASE + 64 * SIZE_1M
    CVI_UPDATE_HEADER_SIZE = SIZE_1K
    CVI_UPDATE_HEADER_ADDR = UIMAG_ADDR + CVI_UPDATE_HEADER_SIZE

    # memory@DRAM_BASE
    KERNEL_MEMORY_ADDR = DRAM_BASE
    KERNEL_MEMORY_SIZE = DRAM_SIZE - FREERTOS_SIZE

    ION_ADDR = DRAM_BASE + 0x3C80000
    ION_SIZE = 65.5 * SIZE_1M

    # Fast image buffer
    H26X_BITSTREAM_ADDR = DRAM_BASE + 39 * SIZE_1M
    H26X_BITSTREAM_SIZE = 2 * SIZE_1M

    H26X_ENC_BUFF_ADDR = H26X_BITSTREAM_ADDR + H26X_BITSTREAM_SIZE
    H26X_ENC_BUFF_SIZE = 0

    ISP_MEM_BASE_ADDR = H26X_ENC_BUFF_ADDR + H26X_ENC_BUFF_SIZE
    ISP_MEM_BASE_SIZE = 10 * SIZE_1M
    FREERTOS_RESERVED_ION_SIZE = H26X_BITSTREAM_SIZE + H26X_ENC_BUFF_SIZE + ISP_MEM_BASE_SIZE
